limit query laravel

59

$products = $art->products->skip(10)->take(10)->get(); //get next 10 rows
skip = OFFSET
$products = $art->products->skip(0)->take(10)->get(); //get first 10 rows
$products = $art->products->skip(10)->take(10)->get(); //get next 10 rows
$users = DB::table('users')->skip(10)->take(5)->get();
$users = DB::table('users')
                ->offset(10)
                ->limit(5)
                ->get();
$report = DB::table('orders')
                ->selectRaw('count(id) as number_of_orders, customer_id')
                ->groupBy('customer_id')
                ->havingBetween('number_of_orders', [5, 15])
                ->get();
$role = $request->input('role');
 
$users = DB::table('users')
                ->when($role, function ($query, $role) {
                    $query->where('role_id', $role);
                })
                ->get();

Comments

Submit
0 Comments